package Text;

public class Demo8 {
    public static void main(String[] args) {
        int sum = 0;
        int temp = 1;//定义阶乘的临时变量
        for (int i = 1; i <= 20; i++) {//循环20次
            for (int j = 1; j <= i; j++) {
                temp = temp * j;
            }
            sum = sum + temp;
            temp = 1;//初始化临时变量
        }
        System.out.println("1+2!+3!+...+20!的和为： " + sum);

    }
}
